import Vue from 'vue'
import Router from 'vue-router'
//import home from '@/components/view/public/home'
import homegu from '@/components/public/home_gu'
import login from '@/components/public/login'
import welcome from '@/components/public/welcome'
import checkStudent from '@/components/manager/view/check_queryStudent'
import checkMoney from '@/components/manager/view/check_queryMoney'
import manageTeacher from '@/components/manager/view/manage_teacher'
import queryEnter from '@/components/manager/view/manage_queryEnter'

import manageStudentThesis from '@/components/manager/view/manage_student_thesis'
// import educationFy from '@/components/manager/view/manage_education'
// import educationAdd from '@/components/manager/view/manage_educationAdd'
import manageThesisLayout from '@/components/manager/view/manage_thesisLayout'


import manageCourse from '@/components/manager/view/manage_course'//课程管理
import manageNotice from '@/components/manager/view/manage_notice'//公告管理
import manageMajor from '@/components/manager/view/manage_major'//专业管理
//
import manageStudent from '@/components/manager/view/manage_student'
import manageStudentPlan from '@/components/manager/view/manage_studentPlan'


Vue.use(Router)

let router = new Router({
  routes: [


    {
      path: '/',
      name:'登陆页',
      component:login
    },
    {
      path: '/login',
      name:'登陆页',
      component:login
    },
    {
      path: '/homegu',   //需要键入的浏览器地址
      name: '主页',      //当前组件页名字
      redirect:'/welcome',  //自动重定向
      component:homegu,   //组件名

      leaf: true, //只有一个节点
      iconCls: 'el-icon-menu', //图标样式class

    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'welcome',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/welcome', component:welcome,name:'主页'}
        ]
    },

    {
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/checkStudent', component:checkStudent,name:'异动审核'}
        ]
    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/checkMoney', component:checkMoney,name:'缴费审核'}
        ]
    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/manageTeacher', component:manageTeacher,name:'教师管理'}
        ]
    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/queryEnter', component:queryEnter,name:'报名审核'}
        ]
    },

    /**
     * 段高喜
     */
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'论文管理',
        leaf:false,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/thesis', component:manageStudentThesis, menuShow:true ,iconCls:'el-icon-menu' ,name:'论文管理'}
          ,{path: '/manageThesisLayout', component:manageThesisLayout,  menuShow:true ,iconCls:'el-icon-menu',name:'论文规范'}
        ]
    },
    // {
    //     path: '/',
    //     component:homegu, //父组件的名字
    //     name:'教学管理',
    //     leaf:true,
    //     menuShow:true,
    //     iconCls:'el-icon-menu',
    //     children: [
    //       {path: '/education', component:educationFy,  menuShow:true,iconCls:'el-icon-menu'  ,name:'教学管理'}
    //       // {path: '/educationAdd', component:educationAdd,  menuShow:true ,iconCls:'el-icon-menu',name:'添加教学计划'}
    //     ]
    // },
    // {
    //   path: '/education',
    //   component:educationFy, //父组件的名字
    //   name:'添加教学计划',
    //   leaf:true,
    //   menuShow:true,
    //   iconCls:'el-icon-menu',
    //   children: [
    //     {path: '/educationAdd', component:educationAdd  ,name:'添加教学计划'}
    //   ]
    // }
     {
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/manageCourse', component:manageCourse,name:'课程管理'}
        ]
    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/manageNotice', component:manageNotice,name:'公告管理'}
        ]
    },
	{
        path: '/',
        component:homegu, //父组件的名字
        name:'主页',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/manageMajor', component:manageMajor,name:'专业管理'}
        ]
    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'学生管理',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/manageStudent', component:manageStudent,name:'学生管理'}
        ]
    },
    {
        path: '/',
        component:homegu, //父组件的名字
        name:'招生计划',
        leaf:true,
        menuShow:true,
        iconCls:'el-icon-menu',
        children: [
          {path: '/manageStudentPlan', component:manageStudentPlan,name:'招生计划'}
        ]
    },

  ]
});

router.beforeEach((to, from, next) => {
let stu = JSON.parse(window.localStorage.getItem('admin-user'));
   if(to.path == '/login' && stu != null){
        if (stu.rememberMe == true) {
          next({ path: '/home' });
       }else{
           window.localStorage.removeItem("admin-user");
           next({ path: '/login' });
       }
   }
   if (stu == null && to.path != '/login') {
       next({ path: '/login' })
   } else {
       next()
   }

});

export default router;
